#include<iostream>
using namespace std;
const int N = 2e6 + 10;
int n, m;
int arr[N];
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &arr[i]);
	}
	while (m--) {
		int x;
		scanf("%d", &x);
		cout << arr[x] << endl;
	}
	
	return 0;
}